<template>
  <div>
    <div class="singer-box">
      <Singer :content="content" />
    </div>
    <div class="pageBox">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="count"
        :page-size="pagelimit"
        :current-page.sync="contnetPage"
        :hide-on-single-page="true"
        @current-change="pageNumChange"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { Search } from "@/api";
import Singer from "@/components/Singer";
export default {
  data() {
    return {
      content: [],
      count: 0,
      pagelimit: 30,
      contnetPage: 1,
    };
  },
  components: {
    Singer,
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      Search({
        keywords: this.$route.query.name,
        limit: this.pagelimit,
        offset: (this.contnetPage - 1) * this.pagelimit,
        type: 100,
      }).then((res) => {
        // console.log(res);
        this.count = res.result.artistCount;
        this.content = res.result.artists;
      });
    },
    pageNumChange(num) {
      this.contnetPage = num;
      this.getData();
    },
  },
};
</script>

<style lang="scss" scoped>
.pageBox {
  text-align: center;
  margin: 20px;
}
.singer-box {
  margin-top: 20px;
}
</style>